﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MatrixOperations;

namespace MatrixTests
{

    //private final double DELTA =0.0001;
    [TestClass]
    public class UnitTest1
    {


       [TestMethod]
        public void canInitialiseMatrix()
        {
            double [,]a = {{1,2},{1,3}};
            Assert.IsNotNull(a);
         }

        [TestClass] 
       public void canCreateaDefaultConstructor()
	{
		Matrix matrix=new Matrix();
		Assert.IsNotNull(matrix);
	}

   [TestClass]
     public void canSetSizeOfMatrixIsEqualToTwo()
	{
		Matrix matrix=new Matrix(2);
		Assert.IsNotNull(matrix);
	}

       [TestMethod]
       public void canIntialiseSingleArrayMatrix()
       {
           double[] a = new double[4];
           Assert.IsNotNull(a);
       }

       [TestMethod]
       public void canIntialiseMultiDimensionalMatrix()
       {
           double[,] a = new double[2, 4];
           Assert.IsNotNull(a);
       }

       [TestMethod]
       public void canIntialiseJaggedMatrix()
       {
           double[][] a = { new double[] {2,3,5}, new double[] {1,3,6,9}};
           Assert.IsNotNull(a);
       }

       [TestMethod]
       public void canFillMatrixElements()
       {
           double[][] a = {new double[] {2,4,5}, new double[] {1,3,6,9}};
           Assert.IsNotNull(a);
       }

        [TestClass] 
        public void canAddMatrices()
	{

		double[][] a = {new double[] {1,2},new double[] {1,2}};
		double [][] b= {new double[] {1,2},new double[] {1,2}};
		Matrix object1=new Matrix(a,2);
		Matrix object2=new Matrix(b,2);
		
		double [][]res = {new double[] {2,4},new double[] {2,4}};
		Matrix object3 = new Matrix(res,2);
		
		Matrix object4 = new Matrix();
		object4 = object1.add(object2);
                
		Assert.Equals(object3,object4);

	}

	  [TestClass]
      public void canSubtractMatrices()
	{

		double[][] a = {new double[] {2,4},new double[] {2,4}};
		double [][] b= {new double[] {1,2},new double[] {1,2}};
		Matrix object1=new Matrix(a,2);
		Matrix object2=new Matrix(b,2);
		
		double [][]res = {new double[] {1,2},new double[] {1,2}};
		Matrix object3 = new Matrix(res,2);
		
		Matrix object4 = new Matrix();
		object4 = object1.subtract(object2);
                
		Assert.Equals(object3,object4);

	}
	
	[TestClass]
	    public void calculateDeterminant2X2()
	    {
	        double [][] matrixData = {{2, 1},{5, 1}};
	        Matrix matrix = new Matrix(matrixData,2);
	        
	        double result = matrix.Determinant();
	        Assert.Equals(-3, result, DELTA);
	    }



       [TestMethod]
       public void canDefineMatrixDeterminant()
       {
           double det = 0;
           Assert.IsNotNull(det);       

       }
    }
}